package com.twu.biblioteca;

public class Movie extends Item {
    private String director;
    private int rating;
    private int year;

    public Movie(String title, String director, int rating, int year, int movieId){
        super(title, movieId);
        this.director = director;
        this.year = year;
        this.rating =rating;
    }

    @Override
    public String toString() {
        return "Movie { " +
                "Title = '"+name+
                "', Director = '" + director + '\'' +
                ", Rating = " + rating +
                ", Year = " + year +
                "}\n";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Movie)) return false;

        Movie movie = (Movie) o;
        if (this.getId()!=movie.getId()) return false;
        if (rating != movie.rating) return false;
        if (year != movie.year) return false;
        if (director != null ? !director.equals(movie.director) : movie.director != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = director != null ? director.hashCode() : 0;
        result = 31 * result + rating;
        result = 31 * result + year;
        return result;
    }
}
